package com.wwq.learn_jpa.controller;

import cn.hutool.core.util.ObjectUtil;
import com.wwq.learn_jpa.model.dto.RightsCategoryDTO;
import com.wwq.learn_jpa.model.entity.RightsCategory;
import com.wwq.learn_jpa.service.RightsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author:wwq
 * @desc:
 * @date 2022/3/17
 */
@RestController
@RequestMapping(value = "/rightscategory")
public class RightsCategoryController {

    @Autowired
    private RightsCategoryService rightsCategoryService;

    /**
     * 对类别进行新增更新操作
     * @param rcDTO
     * @return
     */
    @RequestMapping("/addandupdate")
    private Boolean addAndUpdate(@RequestBody RightsCategoryDTO rcDTO) {
        if (ObjectUtil.isNull(rcDTO)) {
            //只能判断  对象是否为空不能判断空对象2.0
            return false;
        }
        return rightsCategoryService.addAndUpdate(rcDTO);
    }

    /**
     * 权益列表查询
     * @param pageable
     * @return
     */
    @RequestMapping("/page")
    private Page<RightsCategory> page(@RequestBody Pageable pageable){
       return rightsCategoryService.page(pageable);
    }


}
